/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package mtvotingserver;

/**
 *
 * @author David Firth
 */
public class ClientModel {

    private String clientIP;
    private int clientPort;
    private String clientVote = null;
    private boolean voteValid = false;
    private boolean voteConfirmed = false;

    public ClientModel(String clientIP, int clientPort, String clientVote) {
        //Constructor setting attributes to parameterised values
        this.clientIP = clientIP;
        this.clientPort = clientPort;
        this.clientVote = clientVote;
    }

    public String getClientIP() {
        //returns the IP of the client that is voting
        return clientIP;
    }

    public void setClientIP(String clientIP) {
        //sets the clientIP to the passed IP
        this.clientIP = clientIP;
    }

    public int getClientPort() {
        //returns the port address of the client that is voting
        return clientPort;
    }

    public void setClientPort(int clientPort) {
        //sets the clients Port to the passed port number
        this.clientPort = clientPort;
    }

    public String getClientVote() {
        //returns the clients Vote
        return clientVote;
    }

    public void setClientVote(String clientVote) {
        //sets the clients vote to the passed string
        this.clientVote = clientVote;
    }

    public void confirmVote(String vote) {
        //this method is used to confirm is a vote is valid in the
        //voting process.
        if (vote != null) {
            if (vote.toLowerCase().equals(clientVote.toLowerCase())){
                voteValid = true;
            }
            else{
                voteValid = false;
            }
            voteConfirmed = true;
        }
    }

    public boolean isVoteValid() {
        //returns the voteValid boolean value
        return voteValid;
    }

    @Override
    public String toString() {
        return "IP = " + clientIP + ", vote=" + clientVote + 
                ", valid=" + voteValid;
    }
    
    
}
